package com.bigdata.es;

import java.util.ArrayList;
import java.util.List;

public class Task  implements Runnable {

    private List<Listener<String>> listeners = new ArrayList<>();

    public void addListener(Listener<String> listener) {
        listeners.add(listener);
    }

    @Override
    public void run() {
        System.out.println("I am running");
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        for (Listener<String> listener : listeners) {
            listener.notify("done");
        }
    }
}
